{% extends 'front/page/blog/blog_list_base.html' %}

{% block title %}热门博客{% endblock %}

{% block left %}
<div class="card mb-4">
    <div class="card-header bg-primary text-white">最热TOP10</div>
    <div class="card-body p-0">
        <div class="list-group list-group-flush" id="hot-posts-container">
        </div>
    </div>
</div>
{% endblock %}

{% block right %}<div id="posts-container"></div>{% endblock %}



{% block script %}
   <script>

const container = document.getElementById('hot-posts-container');

Every(() => {
    Fetch('{{ url_for('postsrank10tophot') }}', 'get', {}, res => {
        if (res.status === 'success') {
            container.innerHTML = '';  // 清空现有内容（如果需要刷新数据）
            res.data.forEach(pack => {
                container.innerHTML += LeftItem(pack.title, pack.likes, post_detail_url.replace('0',pack.pid));
            });
        }
    });
}, 10000);

const postsContainer = document.getElementById('posts-container');
Fetch('{{  url_for('postslistbyhot') }}','get',{}, res => {
    if (res.status === 'success') {
        res.data.forEach(pack => {
            postsContainer.innerHTML += RightItem(post_detail_url.replace('0',pack.pid), '{{ url_for('static',filename='img/default.png') }}', '#', pack.title, pack.author, pack.time, pack.likes,pack.sort);
        });
    }
});


</script>
{% endblock %}




